﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Hongapo_Common;

public partial class sysadmin_Product_imagelist : PageBase
{
    Hongapo_Services.Product.ProductImage bll = new Hongapo_Services.Product.ProductImage();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindRepetear();
            ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
        }
    }

    private void BindRepetear()
    {
        string strWhere = " 1=1";
        if (!string.IsNullOrEmpty(Request["no"]))
        {
            strWhere =" OrderNo='"+Request["no"]+"'";
            this.btnReturn.Visible = true;
        }
        else if (!string.IsNullOrEmpty(Request["wuxiao"]))
        {
            strWhere = " isopen=0 ";
        }
        int pageindex = TypeConvert.ToInt32(Request["page"], 1);
        DataSet ds = bll.GetList(Pager.PageSize, pageindex, strWhere);
        this.rptList.DataSource = ds.Tables[0];
        if (ds.Tables[1]!=null && ds.Tables[1].Rows.Count>0)
        {
            this.Pager.RecordCount = TypeConvert.ToInt32(ds.Tables[1].Rows[0][0]);
        }
        this.rptList.DataBind();
    }
    protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName.Equals("del"))
        {
            int id = TypeConvert.ToInt32(e.CommandArgument);
            bll.Delete(id);
            BindRepetear();
        }
    }
    protected void btn_Click(object sender, EventArgs e)
    {
        string IDlist = this.hiddenIDList.Value.Trim(',');
        string[] IDArr = IDlist.Split(',');
        for (int i = 0; i < IDArr.Length; i++)
        {
            bll.Delete(TypeConvert.ToInt32(IDArr[i]));
        }
        BindRepetear();
    }
    /// <summary>
    /// 返回
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect(ViewState["UrlReferrer"] as string);
    }
}
